﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class Theme_3_UserControls_ResourceStat : System.Web.UI.UserControl
{
    PowerCreator.LMS.ViewQuery.ViewQuery opViewQuery = new PowerCreator.LMS.ViewQuery.ViewQuery();
    protected PowerCreator.LMS.Web.Config.WebConfig config = new PowerCreator.LMS.Web.Config.WebConfig();
    protected void Page_Load(object sender, EventArgs e)
    {
        BinderResourceCount();
    }

    private void BinderResourceCount()
    {
        //资源统计
        string search = "select count(ResourceClass) as ResourceClassCount,ResourceClass from TResource Group by ResourceClass";
        lbl_Resource1.Text = "0";
        lbl_Resource2.Text = "0";
        lbl_Resource3.Text = "0";
        lbl_Resource4.Text = "0";
        lbl_Resource5.Text = "0";
        int sum=0;
        DataTable dt = opViewQuery.Query(search, 5, 1);
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            sum+=int.Parse(dt.Rows[i]["ResourceClassCount"].ToString());
            if (dt.Rows[i]["ResourceClass"].ToString() == "1")
                lbl_Resource1.Text = dt.Rows[i]["ResourceClassCount"].ToString();
            else if (dt.Rows[i]["ResourceClass"].ToString() == "2")
                lbl_Resource2.Text = dt.Rows[i]["ResourceClassCount"].ToString();
            else if (dt.Rows[i]["ResourceClass"].ToString() == "3")
                lbl_Resource3.Text = dt.Rows[i]["ResourceClassCount"].ToString();
            else if (dt.Rows[i]["ResourceClass"].ToString() == "4")
                lbl_Resource4.Text = dt.Rows[i]["ResourceClassCount"].ToString();
            else if (dt.Rows[i]["ResourceClass"].ToString() == "5")
                lbl_Resource5.Text = dt.Rows[i]["ResourceClassCount"].ToString();
        }
        lbl_AllResourceSum.Text = sum.ToString();
    }

}
